/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page, TreeDataModel } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasVen extends BasicModel<BasVen> {
  code?: string; // 供应商编码
  name?: string; // 供应商名称
  clsCode?: string; // 供应商分类
  venAbbName?: string; // 供应商简称
  venPerson?: string; // 联系人
  venHand?: string; // 联系电话
  venAddress?: string; // 地址
  venEmail?: string; // 邮箱
}

export const basVenList = (params?: BasVen | any) =>
  defHttp.get<BasVen>({ url: adminPath + '/bas/ven/basVen/list', params });

export const basVenListData = (params?: BasVen | any) =>
  defHttp.post<Page<BasVen>>({ url: adminPath + '/bas/ven/basVen/listData', params });

export const basVenForm = (params?: BasVen | any) =>
  defHttp.get<BasVen>({ url: adminPath + '/bas/ven/basVen/form', params });

export const basVenSave = (params?: any, data?: BasVen | any) =>
  defHttp.postJson<BasVen>({ url: adminPath + '/bas/ven/basVen/save', params, data });

export const basVenImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/ven/basVen/importData',
      onUploadProgress,
    },
    params,
  );

export const basVenDisable = (params?: BasVen | any) =>
  defHttp.get<BasVen>({ url: adminPath + '/bas/ven/basVen/disable', params });

export const basVenEnable = (params?: BasVen | any) =>
  defHttp.get<BasVen>({ url: adminPath + '/bas/ven/basVen/enable', params });

export const basVenDelete = (params?: BasVen | any) =>
  defHttp.get<BasVen>({ url: adminPath + '/bas/ven/basVen/delete', params });

export const basVenClsTreeData = (params?: any) =>
  defHttp.get<TreeDataModel[]>({ url: adminPath + '/bas/ven/basVenCls/treeData', params });

export const basVenTreeData = (params?: any) =>
  defHttp.get<TreeDataModel[]>({ url: adminPath + '/bas/ven/basVen/treeData', params });
